<?php
include $this->Render('header.php');
?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_STYLE;?>/css/admin.css" />
<link rel="stylesheet" type="text/css" href="<?php echo BASE_STYLE;?>/css/lightbox.css" />
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo BASE_STYLE;?>/js/lightbox-plus-jquery.js"></script>


<div class="chaxun-box" style="width:685px; height:100%; overflow-y:scroll;overflow-x:hidden">
    <ul class="chaxun-userinfo J-chaxun-userinfo">
        <li>征信对象：<?php echo $this->data['ct_name'];?> </li>
        <li>查询银行：<?php echo $this->data['order']['o_bank'];?></li>
        <li>身份信息</li>
        <li>姓名：<?php echo $this->data['ct_name'];?>&nbsp;&nbsp;&nbsp;&nbsp;性别：<?php echo $this->data['ct_sex'];?>&nbsp;&nbsp;&nbsp;&nbsp;出生：<?php echo $this->data['ct_birth'];?></li>
        <li>身份证地址：<?php echo $this->data['ct_idaddress'];?></li>
        <li>身份证号：<?php echo $this->data['ct_code'];?></li>
        <li>有效期：<?php echo $this->data['ct_validity_start'];?> - <?php echo $this->data['ct_validity_end'];?></li>
        <li>
            <p class="fn-left mr15">文件信息：</p>
            <div class="chaxun-file-box" id="J-chaxun-file-box">
                <img class="example-image" src="<?php echo BASE_ATTACH;?><?php echo $this->data['ct_attach']['fcard'];?>" width="80px" height="80px" alt="" />
                <img class="example-image" src="<?php echo BASE_ATTACH;?><?php echo $this->data['ct_attach']['rcard'];?>" width="80px" height="80px" alt="" />
                <img class="example-image" src="<?php echo BASE_ATTACH;?><?php echo $this->data['ct_attach']['auth'];?>" width="80px" height="80px" alt="" />
                <img class="example-image" src="<?php echo BASE_ATTACH;?><?php echo $this->data['ct_attach']['sign'];?>" width="80px" height="80px" alt="" />
                
            </div>
        </li>
        <li>
            <p class="fn-left mr5">征信结果备注:</p>
            <div class="chaxun-note-box">
                <textarea name="note" class="note" style="resize:none;"><?php echo $this->data['ct_remark'];?></textarea>
                <input type="hidden" name="ct_id" value="<?php echo $this->data['ct_id'];?>" />
            </div>
        </li>
        <li>
            <a class="btn-blue fn-left mr10" href="/order/crolist/option/downdoc?ct_id=<?php echo $this->data['ct_id'];?>">下载doc</a>
            <a class="btn-blue J-baocunjilu" href="javascript:;">保存征信记录</a>
        </li>
    </ul>

    <div class="chaxun-list-box">
    	<p>尚未征信对象</p>
        <table width="100%" cellpadding="0" cellspacing="0" border="0">
        	<tr>
            	<td>序号</td>
                <td>征信对象</td>
                <td>对象类型</td>
                <td>操作</td>
            </tr>
            <?php if(!empty($this->data['cert_all'])) foreach($this->data['cert_all'] as $key => $val){?>
            <tr>
            	<td>&nbsp;<?php echo $val['ct_id'];?></td>
                <td><?php echo $val['ct_name'];?></td>
                <td><?php echo $val['ct_key_text'];?></td>
                <td>
                	<?php
                    	if($val['ct_results'] == '未查询'){
					?>
                    	<a href="javascript:;" class="J-ct-search" data-ctid="<?php echo $val['ct_id'];?>"><?php echo $val['ct_results'];?></a>
                    <?php }else{?>
                		<a href="javascript:;" class="J-ct-search" data-ctid="<?php echo $val['ct_id'];?>"><?php echo $val['ct_results'];?></a>
                	<?php } ?>
                </td>
            </tr>
            <?php } ?>
            
        </table>
    </div>
    <div class="luru-box-btn mt30">
        <a class="a-btn-close mr15 J-a-btn-submit" data-oid="<?php echo $this->data['ct_oid'];?>" href="javascript:;">提交</a>
        <a class="a-btn-close J-a-btn-close" href="javascript:;">关闭</a>
    </div>
    
</div>

<script>
	//关闭弹出
	$(".J-a-btn-close").on('click',function(){
		var winElement = parent.Ext.fly(window.frameElement).up('div.x-window');
		parent.Ext.getCmp(winElement.id).close();
	});

	
	$(document).ready(function(e) {
		//提交征信对象
		$(".J-chaxun-userinfo").on('click','.J-baocunjilu',function(){
			var ctId = $('input[name="ct_id"]').val(),
				ctRemark = $('textarea[name="note"]').val();
				
			$.post('/order/crolist/option/crosearch/',{"ct_id":ctId,"ct_remark":ctRemark},function(data){
				if(data['success']){
					Ext.Msg.alert('提示','保存成功',function(e){
						window.parent.frames["edit_item"].location.reload();		
					});
					
				}else{
					Ext.Msg.alert('提示',data['msg']);
				}
			},'json');	
		});
		
		
		//进行征信查询
		$(".J-ct-search").on('click',function(){
			var ctId = $(this).data('ctid');
			var txt = $(this).text();
			$(this).html('查询中...');
			var that = $(this);
			$.post('/order/crolist/option/croinfo/ajax/1',{"ct_id":ctId},function(data){
				var html="";
					html+='<li>征信对象：'+data['ct_name']+' </li>';
					html+='<li>查询银行：'+data['order']['o_bank']+'</li>';
					html+='<li>身份信息</li>';
					html+='<li>姓名：'+data['ct_name']+'&nbsp;&nbsp;&nbsp;&nbsp;性别：'+data['ct_sex']+'&nbsp;&nbsp;&nbsp;&nbsp;出生：'+data['ct_birth']+'</li>';
					html+='<li>身份证地址：'+data['ct_idaddress']+'</li>';
					html+='<li>身份证号：'+data['ct_code']+'</li>';
					html+='<li>有效期：'+data['ct_validity_start']+' - '+data['ct_validity_end']+'</li>';
					html+='<li>';
					html+='	<p class="fn-left mr15">文件信息：</p>';
					
					html+='	<div class="chaxun-file-box">';
					html+='		<a  href="<?php echo BASE_ATTACH;?>'+data['ct_attach']['fcard']+'" data-lightbox="pic"><img class="example-image" src="<?php echo BASE_ATTACH;?>'+data['ct_attach']['fcard']+'" width="80px" height="80px" /></a>';
					html+='		<a  href="<?php echo BASE_ATTACH;?>'+data['ct_attach']['rcard']+'" data-lightbox="pic"><img src="<?php echo BASE_ATTACH;?>'+data['ct_attach']['rcard']+'" width="80px" height="80px" /></a>';
					html+='		<a  href="<?php echo BASE_ATTACH;?>'+data['ct_attach']['auth']+'" data-lightbox="pic"><img src="<?php echo BASE_ATTACH;?>'+data['ct_attach']['auth']+'" width="80px" height="80px" /></a>';
					html+='		<a  href="<?php echo BASE_ATTACH;?>'+data['ct_attach']['sign']+'" data-lightbox="pic"><img src="<?php echo BASE_ATTACH;?>'+data['ct_attach']['sign']+'" width="80px" height="80px" /></a>';
					html+='	</div>';
					html+='</li>';
					html+='<li>';
					html+='	<p class="fn-left mr5">征信结果备注:</p>';
					html+='	<div class="chaxun-note-box">';
					html+='		<textarea name="note" class="note" style="resize:none;">'+data['ct_remark']+'</textarea>';
					html+='		<input type="hidden" name="ct_id" value="'+data['ct_id']+'" />';
					html+='	</div>';
					html+='</li>';
					html+='<li>';
					html+='	<a class="btn-blue fn-left mr10" href="/order/crolist/option/downdoc?ct_id='+data['ct_id']+'">下载doc</a>';
					html+='	<a class="btn-blue J-baocunjilu" href="javascript:;">保存征信记录</a>';
					html+='</li>';
					$(".J-chaxun-userinfo").html(html);
					
					$(that).html(txt);
			},'json');	
		});
		
		//保存
		$(".J-a-btn-submit").on('click',function(){
			if(!$(this).hasClass('dis')){
				var $this = $(this);
				var oid = $(this).data('oid');
				$this .addClass('dis');
				$.post('/order/crolist/option/crosave/',{"oid":oid},function(data){
					if(data['success']){
						Ext.Msg.alert('提示','提交成功',function(){
							window.parent.location.reload();
						});
						
					}else{
						//alert(data['msg']);
						Ext.Msg.alert('提示',data['msg']);
					}
					
					$this.removeClass('dis');	
				},'json');	
			}
			
		});
		
		
    });
    	var viewerBox = new Viewer(document.getElementById('J-chaxun-file-box'),{
		show:function(){
			viewerBox.update();  	
		}	
	});
	
</script>

<?php include $this->Render('footer.php'); die();?>